<template>
  <div v-loading.lock="loading" class="base-content">
    <div class="basic-info">
      <!--列表-->
      <el-table
        v-loading="tableLoad"
        :data="tableData"
        tooltip-effect="dark"
        style="width: 100%"
      >
        <el-table-column align="center" :label="dataList.number" width="50">
          <template slot-scope="scope">
            {{ scope.$index + 1 }}
          </template>
        </el-table-column>
        <el-table-column prop="workFlowDictName" :label="dataList.ApprovalName" />
        <el-table-column
          v-if="systemType == 'cdc'"
          prop="sampleNum"
          :label="dataList.SampleNumber"
        />
        <el-table-column prop="content" :label="dataList.ContentSummary" />
        <el-table-column prop="remark" :label="dataList.Remark">
          <template slot-scope="scope">
            <div v-html="scope.row.remark"></div>
          </template>
        </el-table-column>
        <el-table-column prop="submitName" :label="dataList.Submitter" />
        <el-table-column prop="submitDate" :label="dataList.SubmitTime" />
        <el-table-column prop="newAuditStatusString" :label="dataList.FinalApprovalStatus" />
        <el-table-column :label="btn.operate" width="140">
          <template slot-scope="{ row }">
            <div class="base-table-operation">
              <el-link v-rights="'detail'" type="primary" @click="detail(row)"
                >{{ btn.Look }}</el-link
              >
            </div>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <WorkFlowGetDetailDialog
      v-if="isShowDialog"
      :page-type="pageType"
      :is-show-dialog.sync="isShowDialog"
      :edit-id="editId"
      :custom-class="customClass"
      :row="rowData"
      :task-data="taskData"
      :report-data="reportData"
      :row-list="tableData"
      :done="false"
      @getList="getList"
    />
  </div>
</template>

<script>
import { getToken } from "../../utils/auth";
import { GetWorkFlowStatusGetList } from "../../api/WorkFlow/WorkFlow";
import WorkFlowGetDetailDialog from "./WorkFlowGetDetailDialog.vue";
export default {
  name: "WorkFlowGetToDo",
  components: {
    WorkFlowGetDetailDialog,
  },
  props: {
    id: {
      type: Number,
      default: 0,
    },
    sampleNum: {
      type: String,
      default: "",
    },
    systemType: {
      type: String,
      default: "",
    },
    remark: {
      type: String,
      default: "",
    },
    submitName: {
      type: String,
      default: "",
    },
    workFlowDictcode: {
      type: String,
      default: "",
    },
    pageInfo: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {
      isShowChildDialog: false,
      reportData: {},
      taskData: {
        id: 0,
        entrustTaskNum: "",
        entrustOrderNumList: "",
        detectionItemName: "",
        sampleInfoName: "",
        sampleInfoNum: "",
        planDetectionDate: "",
        remark: "",
      },
      rowData: {},
      pageType: "",
      showEdit: [40, 60],
      filterForm: {
        auditStatus: 10,
      },
      ruleForm: {
        remark: "",
      },

      token: { Authorization: getToken() },
      visible: false,
      editId: "",
      customClass: "panna-dialog_medium",
      EditIsShowDialog: false,
      isShowDialog: false,
      isShowUpdateDialog: false,
      tableLoad: false,
      loading: false,
      searchLoading: false,
      tableData: [],
      total: 0,
      pageCount: 0,
    };
  },
  computed: {
    btn() {
      return this.$t("ModuleWorkFlow.buttons");
    },
    dataList() {
      return this.$t("ModuleWorkFlow.WorkFlow");
    },
  },
  created() {
    // this.filterForm.id = this.id;
    // this.filterForm.workFlowDictcode = this.workFlowDictcode;
    // this.filterForm.remark = this.remark;
    // this.filterForm.submitName = this.submitName;
    this.getList();
  },
  methods: {
    detail(row) {
      this.rowData = row;
      this.editId = row.auditDataId;
      this.customClass = row.className;
      this.isShowDialog = true;
    },
    cancelForm() {
      this.$refs.filterForm.resetFields();
      this.getList("filter");
    },

    importError() {
      this.loading = false;
      this.$message.error(this.$t("ModuleWorkFlow.buttons.ImportFailure"));
    },
    uploading() {
      this.loading = true;
    },

    close() {
      this.editId = "";
      this.getList();
    },
    getList(flag) {
      this.filterForm.id = this.id;
      this.filterForm.workFlowDictcode = this.workFlowDictcode;
      this.filterForm.remark = this.remark;
      this.filterForm.submitName = this.submitName;
      this.searchLoading = true;
      this.tableLoad = true;
      if (flag) {
        this.pageInfo.pageIndex = 1;
      }
      GetWorkFlowStatusGetList({
        ...this.filterForm,
        ...this.pageInfo,
      })
        .then((res) => {
          // 分页序号连续
          this.tableData = res.data.dataList;
          this.$emit("on-change-page-info", res.data.total);
          this.tableLoad = false;
          this.searchLoading = false;
        })
        .catch(() => {
          this.tableData = [];
          this.tableLoad = false;
          this.searchLoading = false;
        });
    },
    // 切换页码
    changePage(page) {
      this.getList();
    },
    sizeChange(val) {
      this.getList();
    },
    // 新增客户信息
    addUnit() {
      this.isShowDialog = true;
    },
  },
};
</script>
